package com.apes.scm.masterdata.finance.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.scm.masterdata.frame.model.Dept;
import com.apes.scm.masterdata.party.model.PartyRole;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 *
 * @program: apes-server
 * @description 异业不可抵扣部门明细表
 * @author: czs
 * @create: 2021-06-29 16:10
 **/
@Getter
@Setter
@SelectBeforeUpdate
@DynamicUpdate
@DynamicInsert
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name= CrossDept.CONST_TABLE_NAME)
public class CrossDept extends Model {
    public static final String CONST_TABLE_NAME = "mas_cross_dept";

    @Id
    @Column(name="id", length = 32)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "异业不可抵扣部门明细编码", padding = 4)
    @Comment("编码")
    private String id;

    @Comment("门店")
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "dept_id", referencedColumnName = "id", nullable = false)
    private Dept dept;

    @ManyToOne(optional = false)
    @JoinColumn(name = "cross_dic", referencedColumnName = "id", nullable = false)
    @Comment("服务类型编码")
    private CrossDefiIC crossDefiIC;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "company_id", referencedColumnName = "id", nullable = false)
    @Comment("合作公司")
    private PartyRole company;

}
